﻿#include "hoteldetailscomment.h"
#include "ui_hoteldetailscomment.h"
#include <QDebug>

HotelDetailsComment::HotelDetailsComment(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HotelDetailsComment)
{
    ui->setupUi(this);
    m_commentCount = 0;
}

HotelDetailsComment::~HotelDetailsComment()
{
    delete ui;
}

void HotelDetailsComment::setCommentContent()
{
    HotelDetailsCommentContent *commentContent = new HotelDetailsCommentContent();
    m_commentContentVector.push_back(commentContent);
    commentContent->setCommentInfo(GlobalVars::g_localComment);
    ui->listWidget->addItem("");
    ui->listWidget->setItemWidget(ui->listWidget->item(m_commentCount),commentContent);
    ui->listWidget->item(m_commentCount)->setSizeHint(QSize(0, 180));  //每次改变Item的高度
    m_commentCount++;
}

void HotelDetailsComment::setCommentImage(const QString& commentID, const QImage& image)
{
    for (int i = 0; i < m_commentCount; i++)
    {
        if (commentID == m_commentContentVector[i]->getCommentID())
        {
            m_commentContentVector[i]->setCommentImage(image);
            break;
        }
    }
}
